var connect = require('connect');
var http = require('http');
var controller = require('./controller');

var app = connect();
// app.use(connect.favicon('public/favicon.ico'));
// app.use(connect.logger('dev'));
app.use(connect.static('public'));
app.use(connect.directory('public'));
app.use(connect.cookieParser());
app.use(connect.session({ secret: 'session secret' }));

app.use('/hello', function (req, res) {
    controller.hello(req, res);
});
app.use('/oauth', function (req, res) {
    controller.oauth(req, res);
});
app.use('/callback', function (req, res) {
    controller.callback(req, res);
});
app.use('/api/followers', function (req, res) {
    controller.apiFollowers(req, res);
});
app.use('/api/home-timeline', function (req, res) {
    controller.apiHomeTimeline(req, res);
});
app.use('/api/user-timeline', function (req, res) {
    controller.apiUserTimeline(req, res);
});
// 发送一条广播
app.use('/api/statuses-post', function (req, res) {
    controller.apiStatusesPost(req, res);
});

app.use(function (req, res) {
    res.end('Hello from Connect!\n');
});

http.createServer(app).listen(3000);
